package com.qfedu.mbti.controller;


import com.qfedu.mbti.config.SystemConfig;
import com.qfedu.mbti.service.MbtiExamService;
import com.qfedu.mbti.vo.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * MRTI测试表(MbtiExam)表控制层
 *
 * @author makejava
 * @since 2024-11-04 11:43:37
 */
@RestController
@RequestMapping("api/exam")
@Tag(name = "测试模块")
@CrossOrigin
public class MbtiExamController {
    /**
     * 服务对象
     */
    @Resource
    private MbtiExamService service;

    @Operation(summary = "创建测试")
    @GetMapping("create")
    public R create(HttpServletRequest request){
        return service.createExam(request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    @Operation(summary = "开始测试")
    @GetMapping("start")
    public R start(Integer id){
        return service.startExam(id);
    }

    @Operation(summary = "结束测试")
    @GetMapping("end")
    public R end(Integer id){
        return service.endExam(id);
    }
    @Operation(summary = "我的测试")
    @GetMapping("myexams")
    public R myExams(HttpServletRequest request){
        return service.queryMy(request.getHeader(SystemConfig.HEADER_TOKEN));
    }


}

